<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<TITLE>选择机构</TITLE>
<script type="text/javascript" language="JavaScript" src="../script/common.js"></script>
<script type="text/javascript" language="JavaScript" src="../script/tree.js"></script>
<script type="text/javascript" language="JavaScript">
	var tree,funcType,rangeLevel;
	
	function load(){
		rangeLevel = getPara("rangeLevel");
		var orgId = getPara("orgId");
		if (!orgId) orgId= Common.cOrg().id;
		if (!orgId) return;
		var rootName = unesc(getPara("name"));
		var orgLevel = getPara("orgLevel");
		funcType = getPara("funcType");
		if (!funcType) funcType=0
		if (!rootName || !orgLevel){
			DWR.call("partyService.getOrganization", orgId, function(result) {
				showTree(result.organization)
			})
		}else{
			showTree({id:orgId,name:rootName,orgLevel:orgLevel})
		}
	}
	function showTree(obj){
		tree = new LoadTree(obj.name, obj.id,"javascript:void(0)",null,"../images/tree/root.png","../images/tree/root.png");
		tree.obj = obj
		$("orgtree").innerHTML = tree;
	}
	function _startLoadXmlTree(sSrc, jsNode) {
		DWR.call("partyService.findOrganByParentAndLevel",sSrc,rangeLevel,function(result){
			_xmlFileLoaded(result,jsNode);
		});
	}
	
	function _createNode(obj){
		var icon = null;
		var b = obj[2]==700;
		if (funcType == Constants.SELORG_CHILDREN){
			b = true;
			icon = "../images/tree/folder.png";
		}
		var node = createTreeNode(b,obj[1],obj[0],"javascript:void(0)",icon,icon);
		node.obj = {id:obj[0],name:obj[1],orgLevel:obj[2],uniqueId:obj[3]};
		return node;
	}
	
	function onSave(){
        if(!tree.getSelected()){
            showWarning("请选择机构后再点击确定。");
            return;
        }
		var v = tree.getSelected().obj;
		dialogBackValue(v);
	}
	</script>
	</HEAD>
<BODY class="body" onload='load()'>
	<div id="orgtree" class="treeDiv"></div>
</BODY>
</HTML>
